package com.myebills.ebpsfrontend.cust.maxis;

import com.myebills.ebpsfrontend.cust.controller.*;
import com.myebills.ebpsfrontend.cust.utils.*;
import com.checkfree.isolutions.customer.persist.*;
import com.checkfree.isolutions.admin.ObjectId;
import com.checkfree.isolutions.statement.persist.Statement;
import com.checkfree.isolutions.utility.CFiError;
import java.util.Vector;
import java.util.*;
import java.text.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.ibm.logging.ILogger;
import com.ibm.logging.IRecordType;

/**
 * Module Name  : CusConfirmBillDeliveryServlet_v1r00
 * Description  : Bill Delivery Options for customer
 * Last Updated : 2002-10-10
 *
 * @author Meau
 *
 * Remarks :
 *
 */

public class CusConfirmBillDeliveryServlet_v1r00 extends EbppxTransactionServlet {

    ILogger trcLogger = null;

    public void doTransaction(
    HttpServletRequest req,
    HttpServletResponse res)
    throws ServletException {

        final String fName = "doTransaction";
        trcLogger = getTraceLogger(req);

        if (trcLogger.isLogging())
            trcLogger.entry(IRecordType.TYPE_INFO, this, fName);

        try {
            final HttpSession session = req.getSession(false);

            if (null == session)
                throw new IllegalStateException("no session established");

            //Get attribute from session for the logon user
            final EbppxEcsUser ecsUser = (EbppxEcsUser) session.getAttribute(EbppxConstants.ECS_USER);

            EbppxUrlManager urlManager = getUrlManager(req);
            // get the account no selected in JSP
            String strAccNo = urlManager.getRequestParameter("accNo");
            //String billSupressSubscription = urlManager.getRequestParameter("billSupressSubscription");
            String emailDeliverySubcription = urlManager.getRequestParameter("emailDeliverySubscription");
            String smsNotificationSubscription = urlManager.getRequestParameter("smsNotificationSubscription");
            String emailAdd = urlManager.getRequestParameter("emailAdd");
            String mobileNo = urlManager.getRequestParameter("mobileNo");

            String smsNo = "";
            if(mobileNo!=null && !mobileNo.equals("")){
				smsNo = urlManager.getRequestParameter("prefix")+urlManager.getRequestParameter("mobileNo");
			}

            //if an account has been selected then get the statements
            if (strAccNo !=null && !strAccNo.equals("")) {
                if (trcLogger.isLogging())
                    trcLogger.text(IRecordType.TYPE_INFO, this, fName,"requested acc no: "+strAccNo);

                final EbppxBillDeliveryDataBean dataBean = new EbppxBillDeliveryDataBean();
                //dataBean.setPhysicalBillSubscription(billSupressSubscription);
                dataBean.setAcctNo(strAccNo);
                dataBean.setSMSSubscription(smsNotificationSubscription);
                dataBean.setAcctDetailsEmailAdd(emailAdd);
                dataBean.setSMSNo(smsNo);
                dataBean.setEBillSubscription(emailDeliverySubcription);

				req.setAttribute(EbppxConstants.CONFIRM_BILL_SUBSCRIPTIONS, dataBean);
            }

            session.setAttribute("fromPage","5");

            forwardToMappedUrl(req, res, EbppxConstants.URL_JSP_PARAM);
        }
        catch (Throwable t) {
            throw new ServletException(t.toString(), t);
        }
        finally {
            if (trcLogger.isLogging())
                trcLogger.exit(IRecordType.TYPE_INFO, this, fName);
        }

    }

}




